<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

if(!defined('TinyFW')) exit('Access denied!');

class tfFormElementTray extends tfFormElement {

    private $_delimeter = null;
    private $_elements = array();

    public function  __construct($caption, $delimeter='&nbsp;', $name='') {
        $this->setCaption($caption);
        $this->setName($name);
        $this->_delimeter = $delimeter;
    }

    public function isContainer() {
        return true;
    }

    public function getDelimeter(){
        return $this->_delimeter;
    }

    public function addElement($element){
        $this->_elements[] = $element;
    }

    public function render(){
        $count = 0;
        $ret = "";
        if($this->getCaption() <> '') {
            $ret .= "<label>" . $this->getCaption() . "</label>\r\n";
        }
        
        foreach($this->_elements as $element) {
            if($count > 0 && $count < count($this->_elements)) {
                $ret .= $this->getDelimeter();
            }
            if($element->getCaption() != '') {
                $ret .= $element->getCaption() . "&nbsp;";
            }
            $ret .= $element->render();
            $count++;
        }
        return $ret;
    }

    /*
    public function  __toString() {
        $this->render();
    }
    */
}
?>
